import loading from '@/components/xuan-loading/xuan-loading.vue'
import cLabel from "@/components/cat-label/cat-label.vue"

import fromItem from '@/components/from-item/from-item.vue'
import {
	log
} from 'util'
export default {
	props: {
		mustIcon: {
			type: String,
			default: require('@/static/Scope.png'),
		},
		unIcon: {
			type: String,
			default: require('@/static/unscope.png'),
		}
	},
	data() {

		return {
			Inv: 5,


			//文件上传
			uplosdDisabled: false,
			fPhotofilelist: [], //展示数列
			attachmentDetails: [],
			enclosureImg: {},

			dialogPdf: false,
			pdfUrl: "",
			fFileName: "",
			recordfiles: [], //删除合集
			// 弹框

			// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
			size: 10,
			debug: true,
			instantly: true, // 选择文件后是否立即自动上传
			heights: '156rpx',
			count: 8,
			list: [],
			fileList: [], //文件
			fPhotofilelist: [], //处理过程相关资料
			flagNum: -1,
			option: {},




			// loading样式
			width: '150rpx',
			height: '100rpx',
			shadeShow: false,
			backgroundColor: "transparent",
			themeColor: '#33CCCC',
			// loading样式

			// 详情
			totalData: {
				fId: "",
				fProjectid: "",
				fProjectname: "",
				fCompanyid: "",
				fCompanyname: "",
				fCreateuserid: "",
				fCreateusername: "",
				fModifyuserid: "",
				fModifydate: null,
				fModifyusername: "",
				fCheckunit: "", //涉及单位
				fCheckunitid: "", //涉及单位id
				fCheckproject: "", //涉及项目
				fCheckprojectid: "", //涉及项目
				fGridmantype: "", //网格员类别
				fSubgridmanid: "", //指定网格员id
				fSubgridmanname: "", //指定网格员姓名
				fProblemdescription: "", //存在问题简述
				fFileurl: "", //相关现场资料
				fHasproblemdates: "", //发现问题日期
				fReportid: "", //填报人id
				fReportname: "", //填报人
				fReportdates: "", //填报日期
				fCheckresult: "", //处理结果
				fCheckfile: "", //处理过程相关资料
				fCheckdescription: "", //问题处理简述
				fGridmanid: "", //网格员id
				fGridmanname: "", //网格员姓名
				fCheckdates: "", //完成日期
				fStatus: "", //信息状态
				fIsdeleted: "",
			},
			detailsNum: 0,
			userInfo: null, //当前登录用户
			timing: null, //当前年月日
			Fdata: {
				num: null,
			}, //上个页面传过来的参数
			totalData: {
				yjQmpMsGroutinginfo: {
					fId: "", // fid
					fCompanyid: "", // 标段ID
					fCompanyname: "", // 标段名称
					fProjectid: "", // 项目ID
					fProjectname: "", // 项目名称
					fStatus: "",
					fNote: "",
					fIsdeleted: "",
					fBeamyardid: "", // 梁场ID
					fBeamyardname: "", // 梁场名称
					fBeamid: "", // 梁id
					fBeamname: "", // 梁名称
					fEngineeringid: "", // 工程部位id
					fEngineeringname: "", // 工程部位名称
					fMachineid: "", // 设备id
					fMachinename: "", // 设备名称
					fConcretedesignstrength: "", // 砼设计强度
					fWarninglevel: "", // 预警级别 正常 1级 2级 3级
					fAge: "", // 龄期
					fPouringdates: "", // 浇筑时间
					fTensioningdates: "", // 张拉日期
					fCreatedates: "", // 上传时间
				},
				closeinfo: {
					fId: "", // 申请单fid //为空判断为新增
					fParentid: "", // 对应的超标记录fid
					fWarningcontent: "", // 预警内容
					fReason: "", // 问题原因
					fHandleway: "", // 处理方式
					fHandleresult: "", // 处理结果
					fHandledate: null,
					fHandledates: "", // 处理日期
					fHandleusername: null, // 处理人名称
					fHandlefile: null, // 处理附件id
					fFirstcheckresult: null, // 一级审核处理结果
					fFirstcheckopinion: null, // 一级审核处理意见
					fFirstcheckusername: null, // 一级审核处理人name
					fFirstcheckdates: "", // 一级审核处理日期
					fSecondcheckresult: "", // 二级审核处理结果
					fSecondcheckopinion: "", // 二级审核处理意见
					fSecondcheckusername: "", // 二级审核处理人name
					fSecondcheckdates: "", // 二级审核处理日期
					fThirdcheckresult: "", // 三级审核处理结果
					fThirdcheckopinion: "", // 三级审核处理意见
					fThirdcheckusername: "", // 三级审核处理人name
					fThirdcheckdates: "", // 三级审核处理日期
					fFourthcheckresult: "", // 四级审核处理结果
					fFourthcheckopinion: "", // 四级审核处理意见
					fFourthcheckusername: "", // 四级审核处理人name
					fFourthcheckdates: "", // 四级审核处理日期
				},
			},

			fileList: [], //删除文件

			activeNames: ["1"], //处理---折叠
			activeList: ["1"], //详情---折叠

			required0: true, //必填星号
			required1: true,
			required2: true,
			required3: true,
			// required4: true,

			readonly0: true, //是否只读
			readonly1: true,
			readonly2: true,
			readonly3: true,
			// readonly4: false,

			currentDate: false, //年月日选择
			currentDate1: false, //年月日选择
			currentDate2: false, //年月日选择
			currentDate3: false, //年月日选择
			// currentDate4: false, //年月日选择

			companyNum: null, //判断用户身份
		};
	},



	onLoad(options) {
		this.getFdata(options);

		uni.getStorage({ //监督检查方式
			key: 'userInfo',
			success: function(res) {
				this.userInfo = JSON.parse(res.data);
				console.log("this.userInfo", this.userInfo);
				// this.perusalList = this.userInfo.companyId;

			}
		});

		// || MP-WEIXIN || H5
		// #ifdef APP-PLUS
		this.playVideo()
		uni.$on('drawer-page', (data) => {
			that.clickNum(data)
		})
		// #endif
		// #ifdef H5
		this.appliance = 1
		// #endif

	},
	onShow() {

	},
	components: {
		loading,
		cLabel,

		fromItem
	},

	onUnload() {
		uni.$off('drawer-page')
	},

	methods: {

		// 闭合申请单
		Confirm(value) {
			this.totalData.closeinfo.fHandleresult = value;
			this.showPicker = false;
		},
		// 闭合申请单


		onClickLeft() {
			this.$router.push({
				path: "TensionList",
			});
		},

		// 预览
		openPdf(file) {
			// this.dialogPdf = true;

			this.pdfUrl = file.atta.fFilepath.replace(
				"C:",
				"http://1.14.103.201:8301"
			);
			this.fFileName = file.name;
			this.openPdfImg(this.pdfUrl, this.fFileName);
		},
		openPdfImg(url, name) {
			// this.dialogPdf = true;
			// this.pdfUrl = url;
			// this.fFileName = name;
			this.$router.push({
				path: "/pdf",
				query: {
					title: name,
					pathUrl: url
				}
			});
		},


		// 上传文件

		onClick(name) {
			this.detailsNum = name;
		},
		getFdata(data) {
			this.Fdata = data;

			this.companyNum = this.Fdata.Checkstatus;

			this.getDetailData(this.Fdata.id, 0);
		},
		getDetailData(id, num) {
			var that = this;
			this.$http.getGroutingClosedFormByParentId({
					fId: id,
					fCompanyid: this.Fdata.fCompanyid,
				})
				.then((res) => {
					if (res.errcode == 0) {
						that.fileList = [];
						that.totalData = res.data;

						if (that.totalData.yjQmpMsGroutinginfo.fWarninglevel == "0") {
							that.totalData.yjQmpMsGroutinginfo.fWarninglevel = "合格";
						} else if (
							that.totalData.yjQmpMsGroutinginfo.fWarninglevel == "1"
						) {
							that.totalData.yjQmpMsGroutinginfo.fWarninglevel = "不合格";
						}


						// 文件
						that.timestamp = that.totalData.closeinfo.fHandlefile;
						that.fPhotofilelist = that.totalData.fSourcefileList;

						//上传文件
						this.vantLoading = false;
					} else {
						this.vantLoading = false;
						this.$toast.fail(res.msg);
						return false;
					}
				})
				.catch((error) => {
					this.vantLoading = false;
					this.$toast.fail(error.msg);
					return false;
				});
		},


		clickNum(data) {

		},
		onSubmit() {},


		yj_searchForm(num) {
			var that = this
			this.Inv = num
		},




		pdfPage(name, url) {


			let links = encodeURIComponent(url)
			uni.navigateTo({
				url: '/pages/apply/pdf?links=' + links + '&names=' + name,
			})

		},


		callback() {}
	}
}
